﻿using System.Diagnostics;
using AzureStorageMapper.Criterias;
using AzureStorageMapper.Criterias.TableStorage;
using AzureStorageMapper.TableStorage.RESTCommunicate;
using AzureStorageMapper.TableStorage.Utils;

namespace AzureStorageMapper.TableStorage
{
    //public abstract partial class TableEntity
    //{
    //    public static void CreateTable<T>() where T : TableEntity
    //    {
    //        TableInfo tInfo = TableUtilities.GetTableInfo(typeof(T));
    //        TalkToTableStorageProxy.CreateTable(tInfo);
    //    }

    //    public static void DeleteTable<T>() where T : TableEntity
    //    {
    //        TableInfo tInfo = TableUtilities.GetTableInfo(typeof(T));
    //        TalkToTableStorageProxy.DeleteTable(tInfo);
    //    }

    //    public static T GetEntity<T>(string partitionKey, string rowKey)
    //        where T : TableEntity
    //    {
    //        TableInfo tInfo = TableUtilities.GetTableInfo(typeof(T));
    //        return TalkToTableStorageProxy.QueryEntity<T>(tInfo.Name, partitionKey, rowKey);
    //    }

    //    public static QueryEntitiesResult<T> GetEntities<T>(AbstractQuery query = null, int? topCount = null, ContinuationQuery continuation = null)
    //        where T : TableEntity
    //    {
    //        TableInfo tInfo = TableUtilities.GetTableInfo(typeof(T));

    //        string filterStr = null;

    //        if (query != null)
    //        {
    //            filterStr = TableQueryUtils.GetStringQuery(query);

    //            Trace.TraceInformation("Filtering: '{0}' <== '{1}'", tInfo.Name, filterStr);
    //        }

    //        string cQuery = null;

    //        if (continuation != null)
    //        {
    //            cQuery = TableQueryUtils.GetStringQuery(continuation);
    //            Trace.TraceInformation("Continuation: '{0}' <== '{1}'", tInfo.Name, cQuery);
    //        }

    //        if (topCount.HasValue)
    //        {
    //            Trace.TraceInformation("Select top '{0}' entities ...", topCount.Value);
    //        }

    //        return TalkToTableStorageProxy.QueryEntities<T>(tInfo.Name, cQuery, filterStr, topCount);
    //    }
    //}
}
